3fb3f0833393910eee4a4442a307843ad3a55696,cdap-app-fabric/src/main/java/co/cask/cdap/gateway/handlers/NamespaceHttpHandler.java,NamespaceHttpHandler,create,#HttpRequest#HttpResponder#String#,90
Before Change
try {
NamespaceMeta existing = store.createNamespace(builder.build());
if (existing == null) {
responder.sendStatus(HttpResponseStatus.OK);
} else {
responder.sendString(HttpResponseStatus.CONFLICT, String.format("Namespace %s already exists.", namespaceId));
}
After Change
// make the API idempotent, but send appropriate response
String response;
if (existing == null) {
response = String.format("Namespace '%s' created successfully.", namespaceId);
} else {
response = String.format("Namespace '%s' already exists.", namespaceId);
}
responder.sendString(HttpResponseStatus.OK, response);
} catch (Exception e) {
LOG.error("Internal error while creating namespace.", e);
responder.sendStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);